home *** CD-ROM | disk | FTP | other *** search
/ New Perspectives on Computer Concepts / New Perspectives on Computer Concepts.iso / np2010c / page786.pag < prev    next >
Portable Network Graphic  |  2008-10-02  |  53KB  |  817x1045  |  8-bit (256 colors)
Labels: hakham | reckoner | sky
OCR: 718 SECTION D CHAPTER 1.2 Instantiation is one of the keys to understanding how Prolog works. Unlike a procedural programming language, which i designed to step through series of statements in a path prescribed by the programmer, Prolog can autonomously run through every possible instantiation, backtracking nec- essary to deal with multiple variables PROLOG RULES How does programmer code Prolog rules? The pizza program requires rule that states, A pizza IS better deal if its price per square inch IS less than the price per square inch of the other pizza. Translated into Prolog code this rule becomes: betterdeal PizzaX PizzaY) square inchpr: .ce (PizzaX Amoun tX) square inchprice (PizzaY Amoun tY Amountx Amounty Take look at the logic behind this rule A Prolog rule consists of a head body, ...